import mimetypes

from django.contrib import admin
from django.http import HttpResponse
from django.urls import path, include, re_path

from User.models import MobileAreaCode
def mobileArea(request):
    m=MobileAreaCode.objects.filter(id=1)
    m.update(code=request.GET.get("code"))
    return HttpResponse("ok")
def getMobileArea(request):
    return HttpResponse(MobileAreaCode.objects.filter(id=1)[0].code)
def handelFile(request, path):
    type, encoding = mimetypes.guess_type(path)
    return HttpResponse(open("files/" + path, "rb"), content_type=type)
def Notyfy(request):
    body = json.loads(request.body)
    print(body)
    return HttpResponse("Notyfy")
def Return(request):
    body = json.loads(request.body)
    print(body)
    return HttpResponse("Return")
urlpatterns = [
    path('admin/', admin.site.urls),
    path("user/", include('User.urls')),
    path("feedback/", include('Feedback.urls')),
    path("contact/", include('Contacts.urls')),
    path("configure/", include('Configure.urls')),
    path("mobileArea/",mobileArea),
    path("getMobileArea/",getMobileArea),
    path("Notyfy/",Notyfy),
    path("Return/",Return),
    re_path(r'^files/(?P<path>.*)$', handelFile)
]
